﻿using System;
using System.Collections.Generic;
using System.Web.Mvc;
using Ent;

namespace Travel.MVC.Controllers
{
    /// <summary>
    /// 控制器基类
    /// </summary>
    public abstract class ControllerBase : System.Web.Mvc.Controller
    {
        /// <summary>
        /// 用户票据
        /// </summary>
        private UserTicket userTicket;

        public ControllerBase()
        {
            
        }


        #region props

        /// <summary>
        /// 用户票据
        /// </summary>
        /// <remarks>hujiangbo,2011-4-7</remarks>
        public UserTicket CurrentUser
        {
            get
            {
                return this.userTicket;
            }

            private set
            {
                this.userTicket = value;
            }
        }
        #endregion

        /// <summary>
        /// 在执行由操作方法返回的操作结果前调用。
        /// </summary>
        /// <param name="filterContext">有关当前请求和操作结果的信息</param>
        /// <remarks>林守锦 2011/4/16 12:12</remarks>
        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            //// 把当前用户票据加入到视图
            this.ViewBag.CurrentUser = this.CurrentUser;
            base.OnResultExecuting(filterContext);
        }

        /// <summary>
        /// 初始化调用构造函数后可能不可用的数据。
        /// </summary>
        /// <remarks>hujiangbo,2011-4-7</remarks>
        /// <param name="requestContext">HTTP 上下文和路由数据。</param>
        protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        {
            base.Initialize(requestContext);
            //// 初始化用户票据
            this.CurrentUser = Token.GetUserTicket();
        }
    }
}